
import java.io.*;
public class Game {
	
	public static void main(String[] args) throws IOException
	{
		start();
		

	}

	static void start()	throws IOException
	{
		Board b = new Board();
		InputStreamReader isr = new InputStreamReader(System.in) ;
		BufferedReader br = new BufferedReader(isr);

		int start = 0;
		while(start < 9)
		{
			System.out.print("Enter X Co-ordinate(0, 1, 2): ");
			String xString = br.readLine();
			int x = Integer.parseInt(xString);

			System.out.print("Enter Y Co-ordinate(0, 1, 2): ");
			String yString = br.readLine();
			int y = Integer.parseInt(yString);

			if(b.isEmpty(x, y) == true)
			{
				start = start + 1;			
			}

			if(start % 2 == 0)
			{
				b.put(x, y, 'O');
			}
			else
			{
				b.put(x, y, 'X');
			}

//			System.out.print("Enter Value(X, O): ");
//			String valueString = br.readLine();
//			char value = valueString.charAt(0);

			if(b.winner() == 'X' || b.winner() == 'O')
			{
				System.out.println("The Winner is: " + b.winner());
				break;
			}

			if(start == 9)
			{
				System.out.println("The Game is a Draw");
				break;
			}

//			System.out.println("Start is: " + start);

		}



		

	}

}
